/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package UISUTModel.provider;

import UISUTModel.util.UISUTModelAdapterFactory;

import java.util.ArrayList;
import java.util.Collection;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class UISUTModelItemProviderAdapterFactory extends UISUTModelAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UISUTModelItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.UISUT} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UISUTItemProvider uisutItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.UISUT}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUISUTAdapter() {
		if (uisutItemProvider == null) {
			uisutItemProvider = new UISUTItemProvider(this);
		}

		return uisutItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.ApplicationSystem} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ApplicationSystemItemProvider applicationSystemItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.ApplicationSystem}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createApplicationSystemAdapter() {
		if (applicationSystemItemProvider == null) {
			applicationSystemItemProvider = new ApplicationSystemItemProvider(this);
		}

		return applicationSystemItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.UIStatemachine} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UIStatemachineItemProvider uiStatemachineItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.UIStatemachine}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUIStatemachineAdapter() {
		if (uiStatemachineItemProvider == null) {
			uiStatemachineItemProvider = new UIStatemachineItemProvider(this);
		}

		return uiStatemachineItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.UIState} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UIStateItemProvider uiStateItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.UIState}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUIStateAdapter() {
		if (uiStateItemProvider == null) {
			uiStateItemProvider = new UIStateItemProvider(this);
		}

		return uiStateItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.UITransition} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UITransitionItemProvider uiTransitionItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.UITransition}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUITransitionAdapter() {
		if (uiTransitionItemProvider == null) {
			uiTransitionItemProvider = new UITransitionItemProvider(this);
		}

		return uiTransitionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.UserTrigger} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UserTriggerItemProvider userTriggerItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.UserTrigger}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUserTriggerAdapter() {
		if (userTriggerItemProvider == null) {
			userTriggerItemProvider = new UserTriggerItemProvider(this);
		}

		return userTriggerItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.ComponentTrigger} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComponentTriggerItemProvider componentTriggerItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.ComponentTrigger}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createComponentTriggerAdapter() {
		if (componentTriggerItemProvider == null) {
			componentTriggerItemProvider = new ComponentTriggerItemProvider(this);
		}

		return componentTriggerItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.UICondition} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UIConditionItemProvider uiConditionItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.UICondition}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUIConditionAdapter() {
		if (uiConditionItemProvider == null) {
			uiConditionItemProvider = new UIConditionItemProvider(this);
		}

		return uiConditionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.Action} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActionItemProvider actionItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.Action}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createActionAdapter() {
		if (actionItemProvider == null) {
			actionItemProvider = new ActionItemProvider(this);
		}

		return actionItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.UIControl} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UIControlItemProvider uiControlItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.UIControl}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUIControlAdapter() {
		if (uiControlItemProvider == null) {
			uiControlItemProvider = new UIControlItemProvider(this);
		}

		return uiControlItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.UIDataVariable} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UIDataVariableItemProvider uiDataVariableItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.UIDataVariable}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createUIDataVariableAdapter() {
		if (uiDataVariableItemProvider == null) {
			uiDataVariableItemProvider = new UIDataVariableItemProvider(this);
		}

		return uiDataVariableItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.InitialState} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InitialStateItemProvider initialStateItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.InitialState}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createInitialStateAdapter() {
		if (initialStateItemProvider == null) {
			initialStateItemProvider = new InitialStateItemProvider(this);
		}

		return initialStateItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link UISUTModel.FinalState} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected FinalStateItemProvider finalStateItemProvider;

	/**
	 * This creates an adapter for a {@link UISUTModel.FinalState}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createFinalStateAdapter() {
		if (finalStateItemProvider == null) {
			finalStateItemProvider = new FinalStateItemProvider(this);
		}

		return finalStateItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		return super.adapt(notifier, this);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (uisutItemProvider != null) uisutItemProvider.dispose();
		if (applicationSystemItemProvider != null) applicationSystemItemProvider.dispose();
		if (uiStatemachineItemProvider != null) uiStatemachineItemProvider.dispose();
		if (uiStateItemProvider != null) uiStateItemProvider.dispose();
		if (uiTransitionItemProvider != null) uiTransitionItemProvider.dispose();
		if (userTriggerItemProvider != null) userTriggerItemProvider.dispose();
		if (componentTriggerItemProvider != null) componentTriggerItemProvider.dispose();
		if (uiConditionItemProvider != null) uiConditionItemProvider.dispose();
		if (actionItemProvider != null) actionItemProvider.dispose();
		if (uiControlItemProvider != null) uiControlItemProvider.dispose();
		if (uiDataVariableItemProvider != null) uiDataVariableItemProvider.dispose();
		if (initialStateItemProvider != null) initialStateItemProvider.dispose();
		if (finalStateItemProvider != null) finalStateItemProvider.dispose();
	}

}
